package com.learn.yu.aop;

import org.aspectj.lang.ProceedingJoinPoint;

/**
 * @author : Yu.Tan
 * @date : 2023/6/15 15:37
 * @desc : **
 */
public class LogAspect {

    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("-----------------------");
        System.out.println("环绕通知：进入方法！");
        Object o = joinPoint.proceed();
        System.out.println("环绕通知：退出方法！");
        return o;
    }

    public void doBefore() {
        System.out.println("前置通知");
    }

    public void doAfterReturning(String result) {
        System.out.println("后置通知，返回值：" + result);
    }

    /**
     * 异常通知.
     *
     * @param e exception
     */
    public void doAfterThrowing(Exception e) {
        System.out.println("异常通知, 异常: " + e.getMessage());
    }

    /**
     * 最终通知.
     */
    public void doAfter() {
        System.out.println("最终通知");
    }
}
